﻿using ArithCollect;
using Slex;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace CaseMap {
    public class BaseModel : INotifyPc {
        public Command Act { get; set; }
        public object ActParam { get; set; }
        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string pn) {
            if (PropertyChanged != null) {
                this.PropertyChanged.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(pn));
            }
        }
    }
    public class ContainerModel : BaseModel {
        public Dictionary<string, INotifyPc> Items { get; set; }
        public ContainerModel() {
            this.Items = new Dictionary<string, INotifyPc>();
        }
        public ContainerModel(params INotifyPc[] ts) {
            this.Items = new Dictionary<string, INotifyPc>();
            var index = 1;
            foreach (var item in ts) {
                Items.Add("Item" + index++.ToString(), item);
            }
        }
        /// <summary>
        /// 字串索引 帮助设置或访问 INotifyPc的值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public INotifyPc this[string key] {
            get {
                return this.Items[key];
            }
            set {
                this.Items[key] = value;
            }
        }
    }
    /// <summary>
    /// 设计具有绑定动态数据的潜力
    /// </summary>
    public class ShapeModel : DependencyObject, INotifyPc {
        public INotifyPc Entity { get; set; }
        public double Width { get; set; }
        public double Hight { get; set; }
        public double Opacity { get; set; }
        public Brush Fill { get; set; }
        public Brush Stroke { get; set; }
        public Visibility Visibility { get; set; }
        public double Translation { get; set; }
        public double Angle { get; set; }
        public Command Act { get; set; }
        public object ActParam { get; set; }
        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string pn) {
            if (PropertyChanged != null) {
                this.PropertyChanged.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(pn));
            }
        }
    }
    public class MessageModel : BaseModel {
        public string Message { get; set; }
        public static implicit operator MessageModel(string msg) {
            return new MessageModel { Message = msg };
        }
        public static implicit operator string(MessageModel m) {
            return m.Message;
        }
    }
    public class MessageLeabelModel : LabelModel {
        public string Message { get; set; }
    }
    public class StreamModel : BaseModel {
        public byte[] Buffer { get; set; }
        public static implicit operator StreamModel(byte[] data) {
            return new StreamModel { Buffer = data };
        }
        public static implicit operator byte[](StreamModel m) {
            return m.Buffer;
        }
    }
    public class LabelModel : BaseModel {
        public INotifyPc Entity { get; set; }
        public string Title { get; set; }
        public Brush Background { get; set; }
        public Brush Fornground { get; set; }
        public bool IsEnabled { get; set; }
        public double Opercity { get; set; }
        public Visibility Visibility { get; set; }
        public LabelModel() {
            IsEnabled = true;
        }
    }
    public class ContentLabelModel : LabelModel {
        public object Content { get; set; }
    }
    public class ValueLabelModel : LabelModel {
        public double Value { get; set; }
    }
    public class LinkLabelModel : LabelModel {
        public Uri Uri { get; set; }
    }
    public class DateLabelModel : LabelModel {
        public DateTime Date { get; set; }
    }
    public class MarkLabelModel : LabelModel {
        public bool IsChecked { get; set; }
    }
    public class ContentModel : BaseModel {
        public object Content { get; set; }
    }
    public class ValueModel : BaseModel {
        public double Value { get; set; }
        public static implicit operator ValueModel(double data) {
            return new ValueModel { Value = data };
        }
        public static implicit operator double(ValueModel m) {
            return m.Value;
        }
    }
    public class LinkModel : BaseModel {
        public Uri Uri { get; set; }
        public static implicit operator LinkModel(Uri data) {
            return new LinkModel { Uri = data };
        }
        public static implicit operator Uri(LinkModel m) {
            return m.Uri;
        }
    }
    public class DateModel : BaseModel {
        public DateTime Date { get; set; }
        public static implicit operator DateModel(DateTime data) {
            return new DateModel { Date = data };
        }
        public static implicit operator DateTime(DateModel m) {
            return m.Date;
        }
    }
    public class TimeModel : BaseModel {
        public TimeSpan Time { get; set; }
        public static implicit operator TimeModel(TimeSpan data) {
            return new TimeModel { Time = data };
        }
        public static implicit operator TimeSpan(TimeModel m) {
            return m.Time;
        }
    }
    public class MarkModel : BaseModel {
        public bool IsChecked { get; set; }
        public static implicit operator MarkModel(bool data) {
            return new MarkModel { IsChecked = data };
        }
        public static implicit operator bool(MarkModel m) {
            return m.IsChecked;
        }
    }
    public class PopButtonModel : LabelModel {
        public string Title { get; set; }
        public string Title2 { get; set; }
        public string Summary { get; set; }
        public string IconData { get; set; }
        public string IconData2 { get; set; }
        public double? PathWidth { get; set; }
        public double? PathHeight { get; set; }
        public Brush TitleBrush { get; set; }
        public Brush IconBrush { get; set; }
    }
    public class DynamicModel : DynamicTypeBase<DynamicModel>, INotifyPc {
        public INotifyPc Entity { get; set; }
        public DynamicModel(INotifyPc entity = null) {
            this.Entity = entity;
        }
        public new event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string pn) {
            if (this.PropertyChanged != null) {
                this.PropertyChanged.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(pn));
            }
        }
        public Command Act { get; set; }
        public object ActParam { get; set; }
    }
}

